package com.group3.controller;

import com.group3.common.result.ApiResponse;
import com.group3.entity.*;
import com.group3.service.BehaviorCollectService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
/**
 * 行为收集控制器
 */
@RestController
@RequestMapping("/collect")
public class BehaviorCollectController {

    @Resource
    private BehaviorCollectService behaviorCollectService;

    /**
     * 记录用户浏览行为
     * @param behavior
     * @return
     */
    @PostMapping("/browse")
    public ApiResponse<Void> recordBrowse(@RequestBody BrowseBehavior behavior) {
        behaviorCollectService.recordBrowse(behavior);
        return ApiResponse.success();
    }

    /**
     * 记录用户点击行为
     * @param behavior
     * @return
     */
    @PostMapping("/click")
    public ApiResponse<Void> recordClick(@RequestBody ClickBehavior behavior) {
        behaviorCollectService.recordClick(behavior);
        return ApiResponse.success();
    }

    /**
     * 记录用户购买行为
     * @param behavior
     * @return
     */
    @PostMapping("/purchase")
    public ApiResponse<Void> recordPurchase(@RequestBody PurchaseBehavior behavior) {
        behaviorCollectService.recordPurchase(behavior);
        return ApiResponse.success();
    }

    /**
     * 记录用户收藏行为
     * @param behavior
     * @return
     */
    @PostMapping("/favorite")
    public ApiResponse<Void> recordFavorite(@RequestBody FavoriteBehavior behavior) {
        behaviorCollectService.recordFavorite(behavior);
        return ApiResponse.success();
    }

    /**
     * 记录用户评论行为
     * @param behavior
     * @return
     */
    @PostMapping("/comment")
    public ApiResponse<Void> recordComment(@RequestBody CommentBehavior behavior) {
        behaviorCollectService.recordComment(behavior);
        return ApiResponse.success();
    }
}
